package com.jiyinit.web.core.run.service;

import com.jiyinit.web.core.run.dao.TabRunCountDao;
import com.jiyinit.web.core.run.entity.TabRunCountEntity;
import com.jiyinit.web.core.run.vo.RunCountVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Jiyinuser071 on 2018/12/12.
 */
@Service("run.runCountServiceImpl")
public class RunCountServiceImpl {

    @Resource(name = "run.tabRunCountDao")
    private TabRunCountDao tabRunCountDao;

    /**
     * 添加
     * @param entity
     * @return
     */
    public int add(TabRunCountEntity entity){
        return tabRunCountDao.add(entity);
    }

    /**
     * 查询是否已存在数据
     */

    public List<TabRunCountEntity> findCountById(TabRunCountEntity tabRunCountEntity){
        return tabRunCountDao.findCountById(tabRunCountEntity);
    }

    /**
     * 根据userId删除
     */
    public int deleteRunCount(TabRunCountEntity tabRunCountEntity){
        return tabRunCountDao.deleteRunCount(tabRunCountEntity);
    }

    /**
     * 根据userId和dateTime更改
     */
    public int updateRunCount(TabRunCountEntity tabRunCountEntity){
        return tabRunCountDao.updateRunCount(tabRunCountEntity);
    }

    /**
     * 根据日期查询今天所有用户数据
     */
    public List<RunCountVo> selectAllByDateTime(String dateTime,int topOrgId){
        return tabRunCountDao.selectAllByDateTime(dateTime,topOrgId);
    }

    /**
     * 根据userId查询单条数据
     */
    public RunCountVo selectOneByUserId(Integer selectId,String endDate){
        return tabRunCountDao.selectOneByUserId(selectId,endDate);
    }

    /**
     * 查询本周数据
     */
    public List<TabRunCountEntity> findWeekRunCountByUserId(Integer selectId,String startDate,String endDate){
        return tabRunCountDao.findWeekRunCountByUserId(selectId,startDate,endDate);
    }
}
